<%@ page import="br.com.gsc.model.tableMapping.Topic"%>
<%@ page import="java.util.List"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<script type="text/javascript" src="<c:url value='/js/jquery.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/jquery.tinysort.min.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/jquery.tagcloud.min.js' />"></script>
<script>
	$(document).ready(function(){
		$("#xdef").tagcloud({colormin:"d88",colormax:"0a0",height:300});	
	});
	function seta_type(obj){
		document.getElementById('topicType').value = obj;		
	}
</script>
<div id="wrapper">
		<div id="col-left">
		<ul class="topics">
			<c:forEach items="${topics}" var="topic">
				<li>
					<c:set value="${topic.topicType}" var="imgName"/>
					<c:url value="/img/${imgName}.png" var="imgPath"/>
					<div class="topic_thumb"><img class="profile_pic" src="${imgPath}" border="0" alt="img"/></div>
					<div class="topic">
						<table><td>
							<tr class="list_title_post">
								<ul class="icons_actions">
									<sec:authorize url="/admin/**">
										<c:set value="true" var="admin"/>
									</sec:authorize>
									<c:if test="${topic.person.username == logged || admin==true}">
										<li>
											<c:url value="/${company}/produto/${topic.productt}/topico/${topic.id}.html" var="urlEditPost"/>
											<form:form action="${urlEditPost}" method="put">
												<input class="btn_edit" type="submit" value="" />
											</form:form>
										</li>																											
										<li>
											<c:url value="/${company}/produto/${product}/topico/${topic.id}.html" var="urlDeletePost"/>
											<form:form action="${urlDeletePost}" method="delete">
												<input class="btn_delete" type="submit" value=""/>
											</form:form>
										</li>	
									</c:if>		
								</ul>
								<div class="title"><a href="<c:url value="/${topic.product.company.id}/produto/${topic.product.id}/topico/${topic.id}.html"/>">${topic.topicTitle}</a></h4>
								<div class="criadoem">Criado em : ${topic.createdIn}</div>
								<tr><div class="img-user"><img src="/GSC/img/star.png"><c:out value="${topic.person.username}"/></div></tr>							
							</tr>
							<tr>
								<div class="sub-title">
								<c:choose>
									<c:when test="${fn:length(topic.topicContent) > 90}">
										<c:out value="${fn:substring(topic.topicContent,0,90)}"/>...
									</c:when>
									<c:otherwise>
										<c:out value="${topic.topicContent}"/>
									</c:otherwise>
								</c:choose>
								</div>
							</tr>								
						</td></table>
					</div>
				</li>
			</c:forEach>																								
		</ul>
	</div>
	<div id="col-right">		
	</div>
</div>